package com.swordget.entity.vo;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.swordget.entity.TableDesign;
import com.swordget.exception.VerifyFailException;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

/**
 * @Author: David
 * @Date: Created in 14:42 2020/4/14
 * @Description:
 * @Modified By:
 * @Version:
 */
@Data
@Builder
@AllArgsConstructor
public class ExportVo {

    private TableDesign table;

    private String handlerType;

    private String[] serials;

    /**
     * 记录上传文件的id
     */
    private String fileId;

    private String searchParams;

    private String dataStatus;

    private JSONArray queryParams;

    private ExcelVo excel;

    private CsvOrTxtVo csvOrTxtVo;

    private TxtVo txt;

    public JSONArray getQueryParams() {
        if (this.queryParams == null && StringUtils.isNotBlank(searchParams)) {
            try {
                this.queryParams = JSONObject.parseArray(searchParams);
            } catch (Exception e) {
                throw new VerifyFailException("请检查您的参数!", e);
            }
            this.searchParams = null;
        }
        return this.queryParams;
    }




}
